layui.config({
	base : "js/"
}).use(['form','layer','jquery','laypage'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		$ = layui.jquery;

	form.on("submit(createStorage)",function(data){
        console.log(data)
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        $.ajax({
            type:'post',
            url:'/staff/storage/store',
            async:false,
            data:{
                '_token':$('input[name=_token]').val(),
                "name":$('.ae').val(),
                "loc":$('.loc').val(),
                "room_id":$('#room_id').val(),
                "device_id":$("#device").val(),
                "type_id":$("#type").val()       
            },
            dataType:'json',
            success:function (data) {
                if(data.status == 1){
                    top.layer.close(index);
                    top.layer.msg("仓储添加成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                }else{
                    top.layer.close(index);
                    top.layer.msg("仓储添加失败！");
                     layer.closeAll("iframe");
                }
            }
        })
        return false;
    })
});

